<template>
  <DefaultList v-bind="listConfig" />
</template>

<script setup lang="ts">
import DefaultList from '@/components/lists/DefaultList.vue'

const listConfig: TableGlobalType = {
  id: 'tag-list',
  tableKey: 'id',
  table: {
    data: [],
    attrs: {
      stripe: true,
      border: true
    }
  },
  columns: [
    {
      id: '_index',
      attrs: {
        label: '#',
        type: 'index'
      }
    },
    {
      id: 'name',
      attrs: {
        label: '名称',
        prop: 'name',
        width: '120px'
      }
    }
  ],
  pagination: {
    'current-page': 1,
    'page-size': 30,
    total: 0,
    attrs: {
      background: true,
      layout: 'total, sizes, prev, pager, next, jumper'
    }
  },
  search: {
    id: 'tag-list-search-form',
    submitText: '查询',
    submitStyle: {
      'justify-self': 'end'
    },
    resetText: '重置',
    form: {
      action: '/tag',
      method: 'get',
      model: {
        keywords: ''
      },
      attrs: {
        inline: true,
        style: {
          'grid-template-areas': `
                                  "keywords . form-submit"
                              `
        }
      }
    },
    fields: [
      {
        'field-type': 'input',
        'field-label': '',
        id: 'keywords',
        model: 'keywords',
        attrs: {
          placeholder: '请输入关键字搜索'
        },
        'grid-area': 'keywords'
      }
    ]
  },
  detail: {
    form: {
      id: 'tag-detail-form',
      submitText: '详情',
      form: {
        action: '/tag/$1',
        method: 'get',
        model: {},
        attrs: {}
      },
      fields: []
    },
    info: {
      id: 'tag-detail',
      detail: {
        model: {},
        'descriptions-attrs': {
          border: true,
          column: 2
        },
        attrs: {}
      },
      fields: [
        {
          id: 'name',
          'field-type': 'text',
          'field-label': '名称',
          model: 'name',
          'descriptions-item-attrs': {},
          attrs: {}
        },
        {
          id: 'createdAt',
          'field-type': 'text',
          'field-label': '创建时间',
          model: 'createdAt',
          'descriptions-item-attrs': {
            span: 2
          },
          attrs: {}
        }
      ]
    }
  },
  add: {
    id: 'tag-add-form',
    submitText: '新增',
    submitStyle: {
      'justify-self': 'end'
    },
    form: {
      action: '/tag',
      method: 'post',
      model: {
        name: ''
      },
      attrs: {
        'label-width': 80,
        style: {
          gap: '10px',
          'grid-template-areas': `
                                  "name ."
                                  ". form-submit"
                              `
        }
      }
    },
    fields: [
      {
        'field-type': 'input',
        'field-label': '名称',
        id: 'name',
        model: 'name',
        attrs: {},
        'grid-area': 'name'
      }
    ]
  },
  edit: {
    id: 'tag-edit-form',
    submitText: '编辑',
    submitStyle: {
      'justify-self': 'end'
    },
    form: {
      action: '/tag/$1',
      method: 'patch',
      model: {},
      attrs: {
        'label-width': 80,
        style: {
          gap: '10px',
          'grid-template-areas': `
                                  "name ."
                                  ". form-submit"
                              `
        }
      }
    },
    fields: [
      {
        'field-type': 'input',
        'field-label': '名称',
        id: 'name',
        model: 'name',
        attrs: {},
        'grid-area': 'name'
      }
    ]
  },
  remove: {
    id: 'tag-remove-form',
    submitText: '删除',
    form: {
      action: '/tag/$1',
      method: 'delete',
      model: {},
      attrs: {}
    },
    fields: []
  }
}
</script>

<style scoped lang="scss"></style>
